/*
 * BangoProfile.cpp
 *
 *  Created on: 27 Dec 2012
 */

#include "BangoProfile.h"


BangoProfile::BangoProfile()
{
	_profilePosted = false;
}

BangoProfile::~BangoProfile()
{

}

BangoProfile::BangoProfile(int sdkType,
							QString sdkVersion,
							QString applicationId,
							QString applicationType,
							QString applicationChannel,
							QString applicationVersion,
							QString userId,
							int sessionRestartTime,
							int connectionType,
							bool isRoaming,
							QString locationSource,
							double locationAltitude,
							double locationLatitude,
							double locationLongitude,
							float locationAccuracy,
							QString operatorShortName,
							QString operatorName,
							QString operatorCountryIso,
							QString simOperator,
							QString simCardSerial,
							QString device,
							QString model,
							QString hardwareId,
							QString version,
							QString pin,
							QString operatorConnectionType
								)
{
	SetValues(sdkType, sdkVersion, applicationId, applicationType, applicationChannel, applicationVersion, userId, sessionRestartTime, connectionType, isRoaming,
			locationSource, locationAltitude, locationLatitude, locationLongitude, locationAccuracy, operatorShortName, operatorName, operatorCountryIso, simOperator, simCardSerial, device, model, hardwareId, version, pin, operatorConnectionType);

}

void BangoProfile::SetValues(int sdkType,
		 QString sdkVersion,
		                           QString applicationId,
		                           QString applicationType,
		                           QString applicationChannel,
		                           QString applicationVersion,
		                           QString userId,
		                           int sessionRestartTime,
		                           int connectionType,
		                           bool isRoaming,
		                           QString locationSource,
		                           double locationAltitude,
								   double locationLatitude,
								   double locationLongitude,
								   float locationAccuracy,
		                           QString operatorShortName,
		                           QString operatorName,
		                           QString operatorCountryIso,
		                           QString simOperator,
		                           QString simCardSerial,
		                           QString device,
		                           QString model,
		                           QString hardwareId,
		                           QString version,
		                           QString pin,
		                           QString operatorConnectionType
		                           )
{
	_sdkType = sdkType;
	_sdkVersion = sdkVersion;
	_applicationId = applicationId;
	_applicationType = applicationType;
	_applicationChannel = applicationChannel;
	_applicationVersion = applicationVersion;
	_userId = userId;
	_sessionRestartTime = sessionRestartTime;
	_connectionType = connectionType;
	_isRoaming = isRoaming;
	_locationSource = locationSource;
	_locationAltitude = locationAltitude;
	_locationLatitude = locationLatitude;
	_locationLongitude = locationLongitude;
	_locationAccuracy = locationAccuracy;
	_operator = operatorShortName;
	_operatorName = operatorName;
	_operatorCountryIso = operatorCountryIso;
	_simOperator = simOperator;
	_simCardSerial = simCardSerial;
	_device = device;
	_model = model;
	_hardwareId = hardwareId;
	_version = version;
	_pin = pin;
	_operatorConnectionType = operatorConnectionType;

	_profilePosted = false;

}

void BangoProfile::UpdateLocationValues(double locationAltitude, double locationLatitude, double locationLongitude, float locationAccuracy)
{
	_locationAltitude = locationAltitude;
	_locationLatitude = locationLatitude;
	_locationLongitude = locationLongitude;
	_locationAccuracy = locationAccuracy;
}

QVariantMap BangoProfile::GetProfileDetails()
{
	QVariantMap profileDetails;

	profileDetails.insert(BangoFieldNames::POST_SDKTYPE, _sdkType);
	profileDetails.insert(BangoFieldNames::POST_SDKVERSION, _sdkVersion);
	profileDetails.insert(BangoFieldNames::POST_CONNECTIONTYPE, BangoStatic::ConnectionType(_connectionType));
	profileDetails.insert(BangoFieldNames::POST_OPERATORCONNECTIONTYPE, _operatorConnectionType);
	profileDetails.insert(BangoFieldNames::POST_ISROAMING, QVariant(_isRoaming));

	profileDetails.insert(BangoFieldNames::POST_LOCATIONSOURCE, _locationSource);
	profileDetails.insert(BangoFieldNames::POST_LOCATIONACCURACY, QVariant(_locationAccuracy));
	profileDetails.insert(BangoFieldNames::POST_LOCATIONALTITUDE, QVariant(_locationAltitude));
	profileDetails.insert(BangoFieldNames::POST_LOCATIONLATITUDE, QVariant(_locationLatitude));
	profileDetails.insert(BangoFieldNames::POST_LOCATIONLONGITUDE, QVariant(_locationLongitude));

	profileDetails.insert(BangoFieldNames::POST_APPLICATIONID, _applicationId);
	profileDetails.insert(BangoFieldNames::POST_APPLICATIONCHANNEL, _applicationChannel);
	profileDetails.insert(BangoFieldNames::POST_APPLICATIONTYPE, _applicationType);
	profileDetails.insert(BangoFieldNames::POST_APPLICATIONVERSION, _applicationVersion);
	profileDetails.insert(BangoFieldNames::POST_USERID, _userId);
	profileDetails.insert(BangoFieldNames::POST_SESSIONRESTARTTIME, QVariant(_sessionRestartTime));

	profileDetails.insert(BangoFieldNames::POST_OPERATOR, _operator);
	profileDetails.insert(BangoFieldNames::POST_OPERATORNAME, _operatorName);
	profileDetails.insert(BangoFieldNames::POST_COUNTRYISO, _operatorCountryIso);
	profileDetails.insert(BangoFieldNames::POST_SIM_SERIAL, _simCardSerial);
	profileDetails.insert(BangoFieldNames::POST_DEVICEMAKE, _device);
	profileDetails.insert(BangoFieldNames::POST_DEVICEMODEL, _device);
	profileDetails.insert(BangoFieldNames::POST_SIM, _simOperator);
	profileDetails.insert(BangoFieldNames::POST_HARDWAREID, _hardwareId);
	profileDetails.insert(BangoFieldNames::POST_OPERATINGSYSTEMVERSION, _version);
	profileDetails.insert(BangoFieldNames::POST_DEVICEVERSION, _model);

	profileDetails.insert(BangoFieldNames::POST_OPERATINGSYSTEM, BangoStatic::GetOperatingSystemName());

	return profileDetails;
}


